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
570 changes: 0 additions & 570 deletions Refactoring_MD.md

This file was deleted.

49 changes: 49 additions & 0 deletions src/BaseMetadataObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,52 @@ String __fastcall BaseMetadataObject::GetGUID()
return guid;
}

bool __fastcall BaseMetadataObject::HasEditableModuleText()
{
return false;
}

String __fastcall BaseMetadataObject::GetEditableModuleText()
{
return L"";
}

void __fastcall BaseMetadataObject::SetEditableModuleText(const String& value)
{
}

bool __fastcall BaseMetadataObject::SaveEditableModuleText(const String& value, String& errorText)
{
errorText = L"Для этого объекта редактирование модуля не реализовано.";
return false;
}

ModuleTextLocation __fastcall BaseMetadataObject::GetEditableModuleLocation()
{
return ModuleTextLocation();
}

bool __fastcall BaseMetadataObject::HasEditableModuleText(ModuleTextKind kind)
{
return HasEditableModuleText();
}

String __fastcall BaseMetadataObject::GetEditableModuleText(ModuleTextKind kind)
{
return GetEditableModuleText();
}

void __fastcall BaseMetadataObject::SetEditableModuleText(ModuleTextKind kind, const String& value)
{
SetEditableModuleText(value);
}

bool __fastcall BaseMetadataObject::SaveEditableModuleText(ModuleTextKind kind, const String& value, String& errorText)
{
return SaveEditableModuleText(value, errorText);
}

ModuleTextLocation __fastcall BaseMetadataObject::GetEditableModuleLocation(ModuleTextKind kind)
{
return GetEditableModuleLocation();
}
12 changes: 12 additions & 0 deletions src/BaseMetadataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Moxel.h"
#include "Tabular.h"
#include "Form.h"
#include "ModuleTextStorage.h"

//---------------------------------------------------------------------------
// Абстрактный базовый класс для всех объектов метаданных
Expand Down Expand Up @@ -46,6 +47,17 @@ class BaseMetadataObject : public TObject

// Виртуальный метод для инициализации данных из root_data
virtual void __fastcall initializeFromTree() = 0;

virtual bool __fastcall HasEditableModuleText();
virtual String __fastcall GetEditableModuleText();
virtual void __fastcall SetEditableModuleText(const String& value);
virtual bool __fastcall SaveEditableModuleText(const String& value, String& errorText);
virtual ModuleTextLocation __fastcall GetEditableModuleLocation();
virtual bool __fastcall HasEditableModuleText(ModuleTextKind kind);
virtual String __fastcall GetEditableModuleText(ModuleTextKind kind);
virtual void __fastcall SetEditableModuleText(ModuleTextKind kind, const String& value);
virtual bool __fastcall SaveEditableModuleText(ModuleTextKind kind, const String& value, String& errorText);
virtual ModuleTextLocation __fastcall GetEditableModuleLocation(ModuleTextKind kind);
};


Expand Down
35 changes: 29 additions & 6 deletions src/ChartOfAccounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@

#include "Common.h"
#include "ChartOfAccounts.h"
#include "ModuleTextStorage.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

namespace
{
String FindFirstGuid(tree* node)
{
if (!node)
return L"";

String value = Trim(node->get_value());
if (ModuleTextStorage::IsGuidLike(value))
return value;

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

return L"";
}
}

__fastcall TChartOfAccounts::TChartOfAccounts()
: BaseMetadataObject()
Expand Down Expand Up @@ -126,8 +148,9 @@ void __fastcall TChartOfAccounts::initializeFromTree()
curNodeChild = curNodeChild->get_next();
if (curNodeChild)
{
String NameForm = GetNameFormPVH(parent, curNodeChild->get_value());
forms.push_back(std::make_unique<TForm1C>(NameForm, ""));
String formGuid = curNodeChild->get_value();
String NameForm = GetNameFormPVH(parent, formGuid);
forms.push_back(std::make_unique<TForm1C>(NameForm, formGuid));
}
}

Expand All @@ -141,10 +164,11 @@ void __fastcall TChartOfAccounts::initializeFromTree()
int DeltaCom = CountCom - 2;
for (int i = 0; i < CountCom; i++)
{
tree* node_com = root_data.get();
node_com = &(*node_com)[0][3][i+CountCom-DeltaCom][0][1][3][2][9][2];
tree* commandNode = &(*root_data.get())[0][3][i+CountCom-DeltaCom];
String commandGuid = FindFirstGuid(commandNode);
tree* node_com = &(*commandNode)[0][1][3][2][9][2];
String NameCom = node_com->get_value();
comands.push_back(std::make_unique<TComand>(NameCom, ""));
comands.push_back(std::make_unique<TComand>(NameCom, commandGuid));
}
// Получаем макеты
moxels.clear();
Expand All @@ -163,4 +187,3 @@ void __fastcall TChartOfAccounts::initializeFromTree()
}
}
}

35 changes: 30 additions & 5 deletions src/ChartOfCharacteristicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@

#include "Common.h"
#include "ChartOfCharacteristicTypes.h"
#include "ModuleTextStorage.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

namespace
{
String FindFirstGuid(tree* node)
{
if (!node)
return L"";

String value = Trim(node->get_value());
if (ModuleTextStorage::IsGuidLike(value))
return value;

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

return L"";
}
}

__fastcall TChartOfCharacteristicTypes::TChartOfCharacteristicTypes():BaseMetadataObject()
{
}
Expand Down Expand Up @@ -96,8 +119,9 @@ void __fastcall TChartOfCharacteristicTypes::initializeFromTree()
curNodeChild = curNodeChild->get_next();
if (curNodeChild)
{
String NameForm = GetNameFormPVH(parent, curNodeChild->get_value());
forms.push_back(std::make_unique<TForm1C>(NameForm, ""));
String formGuid = curNodeChild->get_value();
String NameForm = GetNameFormPVH(parent, formGuid);
forms.push_back(std::make_unique<TForm1C>(NameForm, formGuid));
}
}

Expand All @@ -112,10 +136,11 @@ void __fastcall TChartOfCharacteristicTypes::initializeFromTree()
int DeltaCom = CountCom - 2;
for (int i = 0; i < CountCom; i++)
{
tree* node_com = root_data.get();
node_com = &(*node_com)[0][6][i+CountCom-DeltaCom][0][1][3][2][9][2];
tree* commandNode = &(*root_data.get())[0][6][i+CountCom-DeltaCom];
String commandGuid = FindFirstGuid(commandNode);
tree* node_com = &(*commandNode)[0][1][3][2][9][2];
String NameCom = node_com->get_value();
comands.push_back(std::make_unique<TComand>(NameCom, ""));
comands.push_back(std::make_unique<TComand>(NameCom, commandGuid));
}
// Получаем макеты
auto& moxels = getLayouts();
Expand Down
139 changes: 81 additions & 58 deletions src/CommonForms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,49 @@ namespace

return L"";
}

String __fastcall GetManagedFormModuleText(tree* root)
{
if (!root || root->get_num_subnode() <= 0)
return L"";

tree* formRoot = root->get_subnode(0);
if (!formRoot || formRoot->get_num_subnode() <= 2)
return L"";

tree* moduleNode = formRoot->get_subnode(2);
if (!moduleNode || moduleNode->get_type() != nd_string)
return L"";

return moduleNode->get_value();
}
}

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

__fastcall TCommonForms::TCommonForms(v8catalog* _parent, const String& _guid) : BaseMetadataObject(_parent, _guid)
{
name = "";
root_data.reset();
text = L"";
textLoaded = false;
textDocument.text = L"";
textDocument.loaded = false;
textDocument.dirty = 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;
textDocument.text = L"";
textDocument.loaded = false;
textDocument.dirty = false;
}

__fastcall TCommonForms::~TCommonForms()
Expand All @@ -76,71 +95,75 @@ void __fastcall TCommonForms::SetFormName(String _name)

void __fastcall TCommonForms::LoadTextIfNeeded()
{
if (textLoaded)
if (textDocument.loaded)
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;
}
}
textDocument = ModuleTextStorage::LoadCommonForm(parent, guid, name);
textDocument.loaded = true;
}

if (text.IsEmpty())
{
std::unique_ptr<tree> form_tree(get_treeFromV8file(data_form));
text = FindEmbeddedModuleText(form_tree.get());
}
}
void __fastcall TCommonForms::RefreshEditableTextIfNeeded()
{
LoadTextIfNeeded();
if (textDocument.location.editable)
return;

textLoaded = true;
ModuleTextDocument refreshed = ModuleTextStorage::LoadCommonForm(parent, guid, name);
if (refreshed.location.editable)
textDocument = refreshed;
}

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

void __fastcall TCommonForms::SetText(String _text)
{
text = _text;
textLoaded = true;
LoadTextIfNeeded();
textDocument.text = _text;
textDocument.loaded = true;
textDocument.dirty = true;
}

ModuleTextDocument& __fastcall TCommonForms::GetTextDocument()
{
RefreshEditableTextIfNeeded();
return textDocument;
}

bool __fastcall TCommonForms::SaveTextToSource(const String& newText, String& errorText)
{
RefreshEditableTextIfNeeded();
return ModuleTextStorage::SaveDocument(textDocument, newText, errorText);
}

bool __fastcall TCommonForms::HasEditableModuleText()
{
RefreshEditableTextIfNeeded();
return !textDocument.text.IsEmpty() || textDocument.location.editable;
}

String __fastcall TCommonForms::GetEditableModuleText()
{
return GetText();
}

void __fastcall TCommonForms::SetEditableModuleText(const String& value)
{
SetText(value);
}

bool __fastcall TCommonForms::SaveEditableModuleText(const String& value, String& errorText)
{
return SaveTextToSource(value, errorText);
}

ModuleTextLocation __fastcall TCommonForms::GetEditableModuleLocation()
{
RefreshEditableTextIfNeeded();
return textDocument.location;
}

std::vector<std::unique_ptr<TRequisite>>& TCommonForms::getAttributes()
Expand Down
Loading
Loading