Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ Compile
*.res
*.rc
docs/
*.ps1
*.ps1
Analize
.clinerules
.continue
10 changes: 5 additions & 5 deletions src/APIcfBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ __fastcall v8catalog::v8catalog(String name)
}
else
{
cfu = new TFileStream(name, fmOpenReadWrite);
cfu = new TFileStream(name, fmOpenReadWrite | fmShareDenyNone);
ZInflateStream(cfu, data);
}
}
Expand All @@ -1077,7 +1077,7 @@ __fastcall v8catalog::v8catalog(String name)
data->WriteBuffer(_empty_catalog_template, 16);
delete data;
}
data = new TFileStream(name, fmOpenReadWrite);
data = new TFileStream(name, fmOpenReadWrite | fmShareDenyNone);
}

file = NULL;
Expand Down Expand Up @@ -1117,7 +1117,7 @@ __fastcall v8catalog::v8catalog(String name, bool _zipped)
delete data;
}

data = new TFileStream(name, fmOpenReadWrite);
data = new TFileStream(name, fmOpenReadWrite | fmShareDenyNone);

file = NULL;

Expand Down Expand Up @@ -1996,9 +1996,9 @@ void __fastcall v8catalog::HalfOpen(const String& name)
Lock->Acquire();

if(is_cfu)
cfu = new TFileStream(name, fmOpenReadWrite);
cfu = new TFileStream(name, fmOpenReadWrite | fmShareDenyNone);
else
data = new TFileStream(name, fmOpenReadWrite);
data = new TFileStream(name, fmOpenReadWrite | fmShareDenyNone);

Lock->Release();
}
Expand Down
9 changes: 1 addition & 8 deletions src/APIcfBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@
typedef System::DynamicArray<System::Byte> ByteArr;

//===========================================================================
const size_t V8_DEFAULT_PAGE_SIZE = 512;
const uint32_t V8_FF_SIGNATURE = 0x7fffffff;

// Для конфигурации старше 8.3.16, без режима совместимости
//const uint64_t V8_FF64_SIGNATURE = 0xffffffffffffffff;
const __int64 V8_FF64_SIGNATURE = 0xffffffffffffffff;
//const size_t V8_OFFSET_8316 = 0x1359; // волшебное смещение, откуда такая цифра неизвестно...
const int V8_OFFSET_8316 = 0x1359; // волшебное смещение, откуда такая цифра неизвестно...
#include "v8_constants.h"


//===========================================================================
Expand Down
34 changes: 32 additions & 2 deletions src/Bots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
//---------------------------------------------------------------------------
#pragma package(smart_init)

namespace
{
tree* GetNodeByPath(tree* root, std::initializer_list<int> indexes)
{
tree* current = root;
if (!current)
return nullptr;

for (int index : indexes)
{
if (!current || index < 0 || index >= current->get_num_subnode())
return nullptr;

current = current->get_subnode(index);
}

return current;
}
}

__fastcall TBots::TBots() : BaseMetadataObject()
{
Expand All @@ -16,12 +35,14 @@ __fastcall TBots::TBots() : BaseMetadataObject()
__fastcall TBots::TBots(v8catalog* _parent, const String& _guid) : BaseMetadataObject(_parent, _guid)
{
botName = "";
initializeFromTree();
root_data.reset();
}

__fastcall TBots::TBots(v8catalog* _parent, const String& _guid, const String& _name) : BaseMetadataObject(_parent, _guid, _name)
{
botName = _name;
initializeFromTree();
root_data.reset();
}

Expand All @@ -37,6 +58,7 @@ String __fastcall TBots::GetBotName()
void __fastcall TBots::SetBotName(String _name)
{
botName = _name;
name = _name;
}

std::vector<std::unique_ptr<TRequisite>>& TBots::getAttributes()
Expand Down Expand Up @@ -66,6 +88,14 @@ std::vector<std::unique_ptr<TForm1C>>& TBots::getForms()

void __fastcall TBots::initializeFromTree()
{
// Инициализация бота из дерева метаданных
// Имя бота уже установлено в конструкторе
tree* nameNode = GetNodeByPath(root_data.get(), {0, 1, 1, 2});
if (nameNode && !nameNode->get_value().IsEmpty())
{
name = nameNode->get_value();
botName = name;
return;
}

if (botName.IsEmpty())
botName = name;
}
12 changes: 6 additions & 6 deletions src/BusinessProceses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
static MetadataTreePaths GetBusinessProcessesPaths()
{
MetadataTreePaths paths;
paths.attIdx = 5;
paths.attIdx = 6;
paths.attItemPath = {0, 1, 1, 1, 2};
paths.tabIdx = 3;
paths.tabIdx = 7;
paths.tabItemPath = {0, 1, 5, 1, 2};
paths.formsIdx = 7;
paths.cmdIdx = 6;
paths.formsIdx = 4;
paths.cmdIdx = 5;
paths.cmdItemPath = {0, 1, 3, 2, 9, 2};
paths.moxIdx = 4;
paths.getFormNameFunc = GetNameFormCatalogs;
paths.moxIdx = 3;
paths.getFormNameFunc = GetNameFormDescriptor;
paths.hasTabulars = true;
return paths;
}
Expand Down
23 changes: 20 additions & 3 deletions src/ChartOfAccounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,27 @@ void __fastcall TChartOfAccounts::initializeFromTree()
int DeltaTab = CountAttTab - 2;
for (int i = 0; i < CountAttTab; i++)
{
tree* node_att_tab = root_data.get();
node_att_tab = &(*node_att_tab)[0][5][i+CountAttTab-DeltaTab][0][1][5][1][2];
tree* tabularNode = &(*root_data.get())[0][5][i+CountAttTab-DeltaTab];
tree* node_att_tab = &(*tabularNode)[0][1][5][1][2];
String NameAttTab = node_att_tab->get_value();
tabulars.push_back(std::make_unique<TTabular>(NameAttTab, ""));
String GuidAttTab;
try {
GuidAttTab = (*tabularNode)[0][1][5][1][1].get_value();
} catch (...) {
GuidAttTab = L"";
}

auto tabular = std::make_unique<TTabular>(NameAttTab, GuidAttTab);
std::unique_ptr<tree> tabularRootData;
if (parent && !GuidAttTab.IsEmpty())
{
v8file* tabularFile = parent->GetFile(GuidAttTab);
if (tabularFile)
tabularRootData.reset(get_treeFromV8file(tabularFile));
}

tabular->initializeFromTree(tabularRootData ? tabularRootData.get() : tabularNode);
tabulars.push_back(std::move(tabular));
}

// Получаем имена форм
Expand Down
23 changes: 20 additions & 3 deletions src/ChartOfCharacteristicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,27 @@ void __fastcall TChartOfCharacteristicTypes::initializeFromTree()
int DeltaTab = CountAttTab - 2;
for (int i = 0; i < CountAttTab; i++)
{
tree* node_att_tab = root_data.get();
node_att_tab = &(*node_att_tab)[0][5][i+CountAttTab-DeltaTab][0][1][5][1][2];
tree* tabularNode = &(*root_data.get())[0][5][i+CountAttTab-DeltaTab];
tree* node_att_tab = &(*tabularNode)[0][1][5][1][2];
String NameAttTab = node_att_tab->get_value();
tabulars.push_back(std::make_unique<TTabular>(NameAttTab, ""));
String GuidAttTab;
try {
GuidAttTab = (*tabularNode)[0][1][5][1][1].get_value();
} catch (...) {
GuidAttTab = L"";
}

auto tabular = std::make_unique<TTabular>(NameAttTab, GuidAttTab);
std::unique_ptr<tree> tabularRootData;
if (parent && !GuidAttTab.IsEmpty())
{
v8file* tabularFile = parent->GetFile(GuidAttTab);
if (tabularFile)
tabularRootData.reset(get_treeFromV8file(tabularFile));
}

tabular->initializeFromTree(tabularRootData ? tabularRootData.get() : tabularNode);
tabulars.push_back(std::move(tabular));
}

// Получаем имена форм
Expand Down
2 changes: 1 addition & 1 deletion src/Class_1CD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7819,7 +7819,7 @@ __fastcall T_1CD::T_1CD(String _filename, MessageRegistrator* _err, bool _monopo

try
{
if(_monopoly) fs = new TFileStream(filename, fmOpenReadWrite | fmShareDenyWrite);
if(_monopoly) fs = new TFileStream(filename, fmOpenReadWrite | fmShareDenyNone);
else fs = new TFileStream(filename, fmOpenRead | fmShareDenyNone);
//fs = new TFileStream(filename, fmOpenRead);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ String __fastcall GetNameFormPVH(v8catalog *cf, String &guid_md)
// return Result;
}

String __fastcall GetNameFormDescriptor(v8catalog *cf, String &guid_md)
{
std::vector<int> path = {0, 1, 1, 2};
return GetNameFromTreePath(cf, guid_md, path);
}

String __fastcall GetNameMoxCatalogs(v8catalog *cf, String &guid_md)
{
Expand Down
1 change: 1 addition & 0 deletions src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ String __fastcall GetNameFromTreePath(v8catalog *cf, String &guid_md, const std:
String __fastcall GetNameFormCatalogs(v8catalog *cf, String &guid_md);
String __fastcall GetNameFormReports(v8catalog *cf, String &guid_md);
String __fastcall GetNameFormPVH(v8catalog *cf, String &guid_md);
String __fastcall GetNameFormDescriptor(v8catalog *cf, String &guid_md);
String __fastcall GetNameMoxCatalogs(v8catalog *cf, String &guid_md);

//---------------------------------------------------------------------------
Expand Down
104 changes: 104 additions & 0 deletions src/CommonForms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,58 @@
//---------------------------------------------------------------------------
#pragma package(smart_init)

namespace
{
bool __fastcall LooksLike1CModuleText(const String& value)
{
return value.Pos(L"Процедура ") > 0
|| value.Pos(L"Функция ") > 0
|| value.Pos(L"КонецПроцедуры") > 0
|| value.Pos(L"КонецФункции") > 0
|| value.Pos(L"\n") > 0;
}

String __fastcall FindEmbeddedModuleText(tree* node)
{
if (!node)
return L"";

if (node->get_type() == nd_string && LooksLike1CModuleText(node->get_value()))
return node->get_value();

for (int i = 0; i < node->get_num_subnode(); i++)
{
String found = FindEmbeddedModuleText(node->get_subnode(i));
if (!found.IsEmpty())
return found;
}

return L"";
}
}

__fastcall TCommonForms::TCommonForms() : BaseMetadataObject()
{
name = "";
root_data.reset();
text = L"";
textLoaded = false;
}

__fastcall TCommonForms::TCommonForms(v8catalog* _parent, const String& _guid) : BaseMetadataObject(_parent, _guid)
{
name = "";
root_data.reset();
text = L"";
textLoaded = false;
}

__fastcall TCommonForms::TCommonForms(v8catalog* _parent, const String& _guid, const String& _name) : BaseMetadataObject(_parent, _guid, _name)
{
name = _name;
root_data.reset();
text = L"";
textLoaded = false;
}

__fastcall TCommonForms::~TCommonForms()
Expand All @@ -39,6 +74,75 @@ void __fastcall TCommonForms::SetFormName(String _name)
name = _name;
}

void __fastcall TCommonForms::LoadTextIfNeeded()
{
if (textLoaded)
return;

text = L"";

if ((parent) && (!guid.IsEmpty()))
{
v8file* data_form = parent->GetFile(guid + ".0");
if (data_form)
{
v8catalog* data_form_cat = new v8catalog(data_form);
if (data_form_cat)
{
auto module_file = data_form_cat->GetFile("module");
if (module_file)
{
data_form_cat->ClearIs8316();
TBytes bytes;
TBytesStream* sb = new TBytesStream(bytes);
module_file->SaveToStream(sb);

TEncoding* enc = nullptr;
TBytes sb_bytes = sb->Bytes;
if (!sb_bytes.empty())
{
int off = TEncoding::GetBufferEncoding(sb_bytes, enc);
if (off > 0)
{
bytes = TEncoding::Convert(enc, TEncoding::Unicode, sb_bytes, off, sb->Size - off);
if (!bytes.empty())
text = String((wchar_t*)&bytes[0], bytes.Length / 2);
}
else
{
text = String((char*)sb->Memory, sb->Size);
}
}

delete sb;
}

delete data_form_cat;
}
}

if (text.IsEmpty())
{
std::unique_ptr<tree> form_tree(get_treeFromV8file(data_form));
text = FindEmbeddedModuleText(form_tree.get());
}
}

textLoaded = true;
}

String __fastcall TCommonForms::GetText()
{
LoadTextIfNeeded();
return text;
}

void __fastcall TCommonForms::SetText(String _text)
{
text = _text;
textLoaded = true;
}

std::vector<std::unique_ptr<TRequisite>>& TCommonForms::getAttributes()
{
return attributes;
Expand Down
Loading
Loading