Files
loongoffice/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
Caolán McNamara 00657aef09 migrate to boost::gettext
* all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl
* all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string")
* ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching
  MODULE .mo files
* UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui
  goes from l10n target to normal one, so the res/lang.zips of UI files go away
* translation via Translation::get(hrc-define-key, imbued-std::locale)
* python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there
  to keep finding the .hrc file uniform) so magic numbers can go away there
* java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation
  mechanism
* en-US res files go away, their strings are now the .hrc keys in the source code
* remaining .res files are replaced by .mo files
* in .res/.ui-lang-zip files, the old scheme missing translations of strings
  results in inserting the english original so something can be found, now the
  standard fallback of using the english original from the source key is used, so
  partial translations shrink dramatically in size
* extract .hrc strings with hrcex which backs onto
   xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap
* extract .ui strings with uiex which backs onto
   xgettext --add-comments --no-wrap
* qtz for gettext translations is generated at runtime as ascii-ified crc32 of
   content + "|" + msgid
* [API CHANGE] remove deprecated binary .res resouce loader related uno apis
      com::sun::resource::OfficeResourceLoader
      com::sun::resource::XResourceBundleLoader
      com::sun::resource::XResourceBundle
    when translating strings via uno apis
      com.sun.star.resource.StringResourceWithLocation
    can continue to be used

Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-07-21 08:20:50 +01:00

299 lines
7.9 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "QueryViewSwitch.hxx"
#include "QueryDesignView.hxx"
#include "QueryTextView.hxx"
#include "querycontainerwindow.hxx"
#include "strings.hrc"
#include "browserids.hxx"
#include "adtabdlg.hxx"
#include "querycontroller.hxx"
#include "sqledit.hxx"
using namespace dbaui;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
OQueryViewSwitch::OQueryViewSwitch(OQueryContainerWindow* _pParent, OQueryController& _rController,const Reference< XComponentContext >& _rxContext)
: m_bAddTableDialogWasVisible(false)
{
m_pTextView = VclPtr<OQueryTextView>::Create(_pParent);
m_pDesignView = VclPtr<OQueryDesignView>::Create( _pParent, _rController, _rxContext );
}
OQueryViewSwitch::~OQueryViewSwitch()
{
// destroy children
m_pDesignView.disposeAndClear();
m_pTextView.disposeAndClear();
}
void OQueryViewSwitch::Construct()
{
m_pDesignView->Construct( );
}
void OQueryViewSwitch::initialize()
{
// initially be in SQL mode
m_pTextView->Show();
m_pDesignView->initialize();
}
bool OQueryViewSwitch::checkStatement()
{
if(m_pTextView->IsVisible())
return true;
return m_pDesignView->checkStatement();
}
OUString OQueryViewSwitch::getStatement()
{
if(m_pTextView->IsVisible())
return m_pTextView->getStatement();
return m_pDesignView->getStatement();
}
void OQueryViewSwitch::clear()
{
if(m_pTextView->IsVisible())
m_pTextView->clear();
else
m_pDesignView->clear();
}
void OQueryViewSwitch::GrabFocus()
{
if ( m_pTextView && m_pTextView->IsVisible() )
m_pTextView->GrabFocus();
else if ( m_pDesignView && m_pDesignView->IsVisible() )
m_pDesignView->GrabFocus();
}
void OQueryViewSwitch::setStatement(const OUString& _rsStatement)
{
if(m_pTextView->IsVisible())
m_pTextView->setStatement(_rsStatement);
}
void OQueryViewSwitch::copy()
{
if(m_pTextView->IsVisible())
m_pTextView->copy();
else
m_pDesignView->copy();
}
bool OQueryViewSwitch::isCutAllowed()
{
if(m_pTextView->IsVisible())
return m_pTextView->isCutAllowed();
return m_pDesignView->isCutAllowed();
}
bool OQueryViewSwitch::isCopyAllowed()
{
if(m_pTextView->IsVisible())
return true;
return m_pDesignView->isCopyAllowed();
}
bool OQueryViewSwitch::isPasteAllowed()
{
if(m_pTextView->IsVisible())
return true;
return m_pDesignView->isPasteAllowed();
}
void OQueryViewSwitch::cut()
{
if(m_pTextView->IsVisible())
m_pTextView->cut();
else
m_pDesignView->cut();
}
void OQueryViewSwitch::paste()
{
if(m_pTextView->IsVisible())
m_pTextView->paste();
else
m_pDesignView->paste();
}
OQueryContainerWindow* OQueryViewSwitch::getContainer() const
{
vcl::Window* pDesignParent = getDesignView() ? getDesignView()->GetParent() : nullptr;
return static_cast< OQueryContainerWindow* >( pDesignParent );
}
void OQueryViewSwitch::impl_forceSQLView()
{
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
// hide the "Add Table" dialog
m_bAddTableDialogWasVisible = pAddTabDialog && pAddTabDialog->IsVisible();
if ( m_bAddTableDialogWasVisible )
pAddTabDialog->Hide();
// tell the views they're in/active
m_pDesignView->stopTimer();
m_pTextView->getSqlEdit()->startTimer();
// set the most recent statement at the text view
m_pTextView->clear();
m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement());
}
void OQueryViewSwitch::forceInitialView()
{
OQueryController& rQueryController( static_cast< OQueryController& >( m_pDesignView->getController() ) );
const bool bGraphicalDesign = rQueryController.isGraphicalDesign();
if ( !bGraphicalDesign )
impl_forceSQLView();
else
{
// tell the text view it's inactive now
m_pTextView->getSqlEdit()->stopTimer();
// update the "Add Table" dialog
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
if ( pAddTabDialog )
pAddTabDialog->Update();
// initialize the design view
m_pDesignView->initByFieldDescriptions( rQueryController.getFieldInformation() );
// tell the design view it's active now
m_pDesignView->startTimer();
}
impl_postViewSwitch( bGraphicalDesign, true );
}
bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
bool bRet = true;
bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign();
if ( !bGraphicalDesign )
{
impl_forceSQLView();
}
else
{
// tell the text view it's inactive now
m_pTextView->getSqlEdit()->stopTimer();
// update the "Add Table" dialog
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
if ( pAddTabDialog )
pAddTabDialog->Update();
// initialize the design view
bRet = m_pDesignView->initByParseIterator( _pErrorInfo );
// tell the design view it's active now
m_pDesignView->startTimer();
}
return impl_postViewSwitch( bGraphicalDesign, bRet );
}
bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess )
{
if ( i_bSuccess )
{
m_pTextView->Show ( !i_bGraphicalDesign );
m_pDesignView->Show ( i_bGraphicalDesign );
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
if ( pAddTabDialog )
if ( i_bGraphicalDesign && m_bAddTableDialogWasVisible )
pAddTabDialog->Show();
GrabFocus();
}
OQueryContainerWindow* pContainer = getContainer();
if ( pContainer )
pContainer->Resize();
m_pDesignView->getController().ClearUndoManager();
m_pDesignView->getController().InvalidateAll();
return i_bSuccess;
}
OAddTableDlg* OQueryViewSwitch::getAddTableDialog()
{
if ( !m_pDesignView )
return nullptr;
return m_pDesignView->getController().getAddTableDialog();
}
bool OQueryViewSwitch::isSlotEnabled(sal_Int32 _nSlotId)
{
return m_pDesignView->isSlotEnabled(_nSlotId);
}
void OQueryViewSwitch::setSlotEnabled(sal_Int32 _nSlotId, bool _bEnable)
{
m_pDesignView->setSlotEnabled(_nSlotId,_bEnable);
}
void OQueryViewSwitch::SaveUIConfig()
{
if(m_pDesignView->IsVisible())
m_pDesignView->SaveUIConfig();
}
void OQueryViewSwitch::SetPosSizePixel( Point _rPt,Size _rSize)
{
m_pDesignView->SetPosSizePixel( _rPt,_rSize);
m_pDesignView->Resize();
m_pTextView->SetPosSizePixel( _rPt,_rSize);
}
Reference< XComponentContext > OQueryViewSwitch::getORB() const
{
return m_pDesignView->getORB();
}
bool OQueryViewSwitch::reset()
{
m_pDesignView->reset();
if ( !m_pDesignView->initByParseIterator( nullptr ) )
return false;
if ( switchView( nullptr ) )
return false;
return true;
}
void OQueryViewSwitch::setNoneVisbleRow(sal_Int32 _nRows)
{
if(m_pDesignView)
m_pDesignView->setNoneVisbleRow(_nRows);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */